Skip to content

Update ZisK to 0.16.0#296

Open
han0110 wants to merge 7 commits intomasterfrom
han/feature/zisk-v0.16.0
Open

Update ZisK to 0.16.0#296
han0110 wants to merge 7 commits intomasterfrom
han/feature/zisk-v0.16.0

Conversation

@han0110
Copy link
Collaborator

@han0110 han0110 commented Feb 19, 2026

  • Update zisk to v0.16.0. Resolves Update zisk to v0.16.0 #308
  • Use zisk-sdk instead of using cargo-zisk. Resolves Use ZisK's SDK #73
    • No need to setup explicitly, the prover now runs setup automatically if it's setup yet
    • Use local prover instead of server, recovery from failure by cleaning up ASM services manually
  • Add stock rust Compiler impl RustRv64ima with target spec as json (supercedes Add rust stock compiler. #107, which has ZisK's stock rust compiler left unmerged)

@han0110 han0110 force-pushed the han/feature/zisk-v0.16.0 branch 3 times, most recently from a2e9c52 to a3bbf87 Compare February 26, 2026 14:56
@han0110 han0110 force-pushed the han/feature/zisk-v0.16.0 branch from a3bbf87 to e55bb73 Compare March 2, 2026 17:38
@han0110 han0110 force-pushed the han/feature/zisk-v0.16.0 branch from e55bb73 to 14d7003 Compare March 13, 2026 14:05
@han0110 han0110 changed the title [WIP] Update ZisK to 0.16.0 Update ZisK to 0.16.0 Mar 17, 2026
@han0110 han0110 force-pushed the han/feature/zisk-v0.16.0 branch 2 times, most recently from f5213da to d936d54 Compare March 17, 2026 09:13
@han0110 han0110 marked this pull request as ready for review March 17, 2026 10:31
@han0110 han0110 force-pushed the han/feature/zisk-v0.16.0 branch from d936d54 to bc7040e Compare March 17, 2026 10:44
let digest = D::digest(P::Io::serialize_output(&output).unwrap());
assert_eq!(&*digest, public_values)
assert_eq!(&*digest, &public_values[..digest.len()]);
assert!(public_values[digest.len()..].iter().all(|byte| *byte == 0));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because ZisK now outputs fixed 256 bytes public values, so here we check the rest of the bytes to be zero.

}
}

fn assembly_files_exist(elf_hash: Hash) -> bool {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined the ASM files existence check because the exported function requires a ELF path.

Comment on lines +174 to +177
let _ = Command::new("fuser")
.args(["-k", "-9", "23115/tcp", "23116/tcp", "23117/tcp"])
.output();
sleep(Duration::from_secs(1));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forcely remove the process to make sure recovery from ASM services panic.

Comment on lines +32 to +33
/// Merkle root of ROM trace.
pub type ProgramVk = [u8; 32];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed from RomDigest, ZisK calls the value ProgramVk now

}

info!("Command `cargo-zisk check-setup --aggregation` succeeded");
fn compute_program_vk(elf: &[u8]) -> Result<ProgramVk, Error> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined the cargo-zisk rom-setup because there is no method exported to do so directly

Comment on lines +252 to +258
let mut aligned = ManuallyDrop::new(vec![0u64; data.len() / 8]);
bytemuck::cast_slice_mut(&mut aligned).copy_from_slice(&data);
let ptr = aligned.as_mut_ptr().cast::<u8>();
let len = aligned.len() * size_of::<u64>();
let cap = aligned.capacity() * size_of::<u64>();
// SAFETY: `ptr` came from a `Vec<u64>` allocation.
unsafe { Vec::from_raw_parts(ptr, len, cap) }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously the way (to_vec()) actually doesn't guarantee the bytes to be aligned, so here we need to use Vec::from_raw_parts with ManuallyDrop to make sure the alignment is preserved.

/// Returns `data` with a LE u64 length prefix and padding to multiple of 8.
///
/// The length prefix and padding is expected by ZisK emulator/prover runtime.
fn length_prefixed_and_padded(data: &[u8]) -> Vec<u8> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now ZisK requires input to be prefixed with u64 LE length, and padded to multiple of 8

CommonError, Input, ProgramExecutionReport, ProgramProvingReport, Proof, ProofKind,
ProverResource, PublicValues, zkVM, zkVMProgramDigest,
};
use mpi as _; // Import symbols referenced by starks_api.cpp
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To run the rom_merkle_setup we have to initialize the MpiCtx, however if mpi is enabled it the MpiCtx can't be initialized twice, so we disable the mpi feature by disable_distributed.

However, there is still some code references the mpi symbols, so here we still need to import it..

Comment on lines +24 to +25
c: input.c.wrapping_mul(input.a as u32).wrapping_add(1),
d: input.d.wrapping_mul(input.b as u64).wrapping_add(1),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZisK prover panics when some AIR has empty trace, so here we add some multiplication operation

@han0110 han0110 force-pushed the han/feature/zisk-v0.16.0 branch from bc7040e to fa3983b Compare March 17, 2026 14:09
Copy link
Collaborator

@jsign jsign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Left some nit comments/questions.

fn uninitialize(mut prover_and_pk: MutexGuard<Option<(ZiskProver<Asm>, ZiskProgramPK)>>) {
info!("Uninitializing ZisK prover...");

let _ = Command::new("fuser")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creative :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update zisk to v0.16.0 Use ZisK's SDK

2 participants